package designPattern.ObserverPattern1;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jiangwz
 * @create 2019/10/30.
 */
public class GamePub implements Pub {

    List<Sub> subs = new ArrayList<>();

    @Override
    public void registerSub(Sub sub) {
        subs.add(sub);
    }

    @Override
    public void removeSub(Sub sub) {
        subs.remove(sub);
    }

    @Override
    public void publish(String msg) {
        subs.forEach(sub -> sub.receive(msg));
    }
}
